﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Enemy : MonoBehaviour
{
    protected Collider2D enemyCollider;
    protected AudioSource deathSource;
    protected Animator anim;
    protected virtual void Start()
    {
        enemyCollider = GetComponent<Collider2D>();
        deathSource = GetComponent<AudioSource>();
        anim = GetComponent<Animator>();
    }
    public void Destroy()
    {
        //Debug.Log("destroy");
        Destroy(gameObject);
    }
    public void Death()
    {
        anim.SetTrigger("death");
        deathSource.Play();
        GetComponent<Collider2D>().enabled = false;
        GetComponent<Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeAll;
    }
}
